<?php

if (!defined('PHOX') or !constant('PHOX')) die('Direct access not allowed!');

/**
 * Session 
 * 
 * @package lib
 * @version 0.1
 * @author Pedro Eugénio <voxmachina@sapo.pt> 
 * @license GPL v.3
 */
class Session 
{
    
 /**
  * __construct 
  * 
  * @access protected
  * @return void
  */
  function __construct()
  {
    if( !session_start() ) 
      session_start();
  }

 /**
  * set 
  * 
  * @param mixed $key 
  * @param mixed $val 
  * @access public
  * @return void
  */
  function set( $key , $val )
  {
    $_SESSION[ $key ] = $val;
  }

 /**
  * _unset 
  * 
  * @access protected
  * @return void
  */
  function _unset() 
  {
    $_SESSION = array();
  }
    
 /**
  * get 
  * 
  * @param mixed $key 
  * @access public
  * @return void
  */
  function get( $key )
  {
    if( !empty( $_SESSION[ $key ] ) ) 
    {
      return $_SESSION[ $key ];
    } else {
      return false;
    }
  }
    
 /**
  * setData 
  * 
  * @param array $data 
  * @access public
  * @return void
  */
  function setData($data = array())
  {
    if( is_array( $data ) )
    {
      foreach( $data as $key => $val )
      {
        $_SESSION[ $key ] = $val;
      }
    }
  }
  
}

?>
